<?php

namespace common\jobs\notice;

use Yii;
use yii\base\Exception;
use common\jobs\base\IntervalRetryableJob;
use common\jobs\handle\BusinessNotifyHandle;

/**
 * 业务支付消息通知队列
 *
 * @author emhome <emhome@163.com>
 * @since 1.0
 * @property string $uniqueCacheId
 */
class BusinessNotifyJob extends IntervalRetryableJob {

    /**
     * @inheritdoc
     */
    public $trade_id = null;

    /**
     * @param \yii\queue\Queue $queue
     * @return mixed|void
     * @throws Exception
     */
    public function execute($queue) {
        $model = new BusinessNotifyHandle();
        $model->trade_id = $this->trade_id;
        $model->job = $this;
        return $model->save();
    }

    /**
     * 间隔时间缓存ID
     *
     * @inheritdoc
     */
    public function getUniqueCacheId() {
        return static::class . '_' . $this->order_id;
    }

}
